package org.zfes.snowier.cloud.zbss.cms.router.service.topic;

import java.util.Map;
import java.util.Optional;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.zfes.snowier.core.data.DataSet;
import org.zfes.snowier.web.controller.BaseController;
import org.zfes.snowier.cloud.zbss.cms.topic.model.CmsTopic;
import org.zfes.snowier.cloud.zbss.cms.topic.service.ICmsTopicService;
@Controller 
@RequestMapping("/cms/topic/cmsTopic")
public class CmsTopicController extends BaseController {

	
	@Autowired
	private ICmsTopicService cmsTopicService;
	
	@RequiresPermissions(value="cmsTopic:loadCmsTopicDataSet",desc="专题列表")
    @RequestMapping(value="/loadCmsTopicDataSet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTopicDataSet(@RequestParam Map<String,Object> params){
	    DataSet dataSet=  cmsTopicService.loadCmsTopicDataSet(params);
	    return ajaxQuery("dataSet", dataSet);
    }
	
	@RequiresPermissions(value="cmsTopic:createCmsTopic",desc="专题添加")
    @RequestMapping(value="/createCmsTopic", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public  @ResponseBody Object createCmsTopic(CmsTopic cmsTopic,String columnIdSet,long modelId){
		cmsTopicService.createCmsTopic(cmsTopic,columnIdSet,modelId);
    	return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTopic:loadCmsTopic",desc="专题加载")
    @RequestMapping(value="/loadCmsTopic", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object loadCmsTopic(Long id){
		Optional<CmsTopic> ops = cmsTopicService.loadCmsTopicById(id);
		return ajaxQuery("cmsTopic",ops);
    }
	
	@RequiresPermissions(value="cmsTopic:updateCmsTopic",desc="专题更新")
    @RequestMapping(value="/updateCmsTopic", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object updateCmsTopic(CmsTopic cmsTopic){
		cmsTopicService.updateCmsTopic(cmsTopic);
		return ajaxDoneSuccess("数据操作成功 ");
    }
	
	@RequiresPermissions(value="cmsTopic:deletCmsTopic",desc="专题删除")
    @RequestMapping(value="/deleteCmsTopic", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public @ResponseBody  Object deleteCmsTopic(Long id){
		cmsTopicService.deleteCmsTopic(id);
		return ajaxDoneSuccess("数据操作成功 ");
    }

}